package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AgvState;
import com.ruoyi.system.service.IAgvStateService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * AGV小车状态 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-22
 */
@Controller
@RequestMapping("/system/agvState")
public class AgvStateController extends BaseController
{
    private String prefix = "system/agvState";
	
	@Autowired
	private IAgvStateService agvStateService;
	
	@RequiresPermissions("system:agvState:view")
	@GetMapping()
	public String agvState()
	{
	    return prefix + "/agvState";
	}
	
	/**
	 * 查询AGV小车状态列表
	 */
	@RequiresPermissions("system:agvState:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(AgvState agvState)
	{
		startPage();
        List<AgvState> list = agvStateService.selectAgvStateList(agvState);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出AGV小车状态列表
	 */
	@RequiresPermissions("system:agvState:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AgvState agvState)
    {
    	List<AgvState> list = agvStateService.selectAgvStateList(agvState);
        ExcelUtil<AgvState> util = new ExcelUtil<AgvState>(AgvState.class);
        return util.exportExcel(list, "agvState");
    }
	
	/**
	 * 新增AGV小车状态
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存AGV小车状态
	 */
	@RequiresPermissions("system:agvState:add")
	@Log(title = "AGV小车状态", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(AgvState agvState)
	{		
		return toAjax(agvStateService.insertAgvState(agvState));
	}

	/**
	 * 修改AGV小车状态
	 */
	@GetMapping("/edit/{agvCode}")
	public String edit(@PathVariable("agvCode") String agvCode, ModelMap mmap)
	{
		AgvState agvState = agvStateService.selectAgvStateById(agvCode);
		mmap.put("agvState", agvState);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存AGV小车状态
	 */
	@RequiresPermissions("system:agvState:edit")
	@Log(title = "AGV小车状态", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(AgvState agvState)
	{		
		return toAjax(agvStateService.updateAgvState(agvState));
	}
	
	/**
	 * 删除AGV小车状态
	 */
	@RequiresPermissions("system:agvState:remove")
	@Log(title = "AGV小车状态", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(agvStateService.deleteAgvStateByIds(ids));
	}
	
}
